package com.justnow.offer;


import java.math.BigInteger;
import java.util.Scanner;

/**
 * @author justnow
 * Created on 2020-10-02
 * Description
 */
public class Shenwang01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        BigInteger m = new BigInteger("1");
        while (!m.mod(new BigInteger(String.valueOf(n))).equals(new BigInteger("0"))) {
            m = m.multiply(new BigInteger("10")).add(new BigInteger("1"));
        }
        System.out.println(m.toString().length());
    }
}
